﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
using SAKS.Models;
using NHibernate.Criterion;
namespace SAKS.Services.Query
{
    class PagedAwardsSearch : PagedQueryOverBase<Award>
    {
        public PagedAwardsSearch(ISession session) : base(session) { }
        public string Key { get; set; }
        protected override IQueryOver<Award, Award> GetQuery()
        {
            var query = Session.QueryOver<Award>();
            if(!string.IsNullOrEmpty(Key))
                query.WhereRestrictionOn( a=> a.Name)
                    .IsInsensitiveLike(Key,MatchMode.Anywhere);

            query.OrderBy(a => a.Name);
            return query;
        }
    }
}
